/** * This file holds javscript functions that are used by the templates in the Theme * */ // AJAX FUNCTIONS function loadNewPage( el, url ) { var theEl = $(el); var callback = { success : function(responseText) { theEl.innerHTML = responseText; if( Slimbox ) Slimbox.scanPage(); } } var opt = { // Use POST method: 'get', // Handle successful response onComplete: callback.success } new Ajax( url + '&only_page=1', opt ).request(); } function handleGoToCart() { document.location = live_site + '/index.php?option=com_virtuemart&page=shop.cart&product_id=' + formCartAdd.product_id.value + '&Itemid=' +formCartAdd.Itemid.value; } var timeoutID = 0; function handleAddToCart( formId, parameters ) { formCartAdd = document.getElementById( formId ); var callback = function(responseText) { updateMiniCarts(); // close an existing mooPrompt box first, before attempting to create a new one (thanks wellsie!) if (document.boxB) { document.boxB.close(); clearTimeout(timeoutID); } document.boxB = new MooPrompt(notice_lbl, responseText, { buttons: 2, width:400, height:150, overlay: false, button1: ok_lbl, button2: cart_title, onButton2: handleGoToCart }); setTimeout( 'document.boxB.close()', 3000 ); } var opt = { // Use POST method: 'post', // Send this lovely data data: $(formId), // Handle successful response onComplete: callback, evalScripts: true } new Ajax(formCartAdd.action, opt).request(); } /** * This function searches for all elements with the class name "vmCartModule" and * updates them with the contents of the page "shop.basket_short" after a cart modification event */ function updateMiniCarts() { var callbackCart = function(responseText) { carts = $$( '.vmCartModule' ); if( carts ) { try { for (var i=0; i -1 || navigator.appVersion.indexOf("msie 6") > -1) ) { document.writeln(''); window.attachEvent("onload", fnLoadPngs); } function fnLoadPngs() { var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, ''); var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5); for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) { if (itsAllGood && img.src.match(/(.*)\/com_virtuemart\/(.*)\.png$/i) != null) { fnFixPng(img); img.attachEvent("onpropertychange", fnPropertyChanged); } img.style.visibility = "visible"; } var nl = document.getElementsByTagName("INPUT"); for (var i = nl.length - 1, e = null; (e = nl[i]); i--) { if (e.className && e.className.match(/\bimage\b/i) != null) { if (e.src.match(/\.png$/i) != null) { fnFixPng(e); e.attachEvent("onpropertychange", fnPropertyChanged); } e.style.visibility = "visible"; } } } function fnPropertyChanged() { if (window.event.propertyName == "src") { var el = window.event.srcElement; if (!el.src.match(/x\.gif$/i)) { el.filters.item(0).src = el.src; el.src = "x.gif"; } } } function dbg(o) { var s = ""; var i = 0; for (var p in o) { s += p + ": " + o[p] + "\n"; if (++i % 10 == 0) { alert(s); s = ""; } } alert(s); } function fnFixPng(img) { var src = img.src; img.style.width = img.width + "px"; img.style.height = img.height + "px"; img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"; img.src = "components/com_virtuemart/shop_image/blank.gif"; }var MooPrompt = box = new Class({ setOptions: function(options){ this.options = { buttons: 1, width: 300, // Set width of the box height: 0, // Set height of the box (0 = sized to content) maxHeight:100, // Maximum height of the dialog box vertical: 'middle', // top middle bottom horizontal: 'center', // left center right delay: 0, // Delay before closing (0=no delay) overlay: true, // Cover the page showCloseBtn: true, effect: 'grow' // 'grow' - Expands box from a middle point and fades in content // 'slide' - Slides in the box from the nearest side. // button1: 'Ok' --- supply this for setting button text // onButton1: function --- supply function for button action }; // Object.extend(this.options, options || {}); $extend(this.options, options || {}); // code modified by JK for mootools 1.2 }, initialize: function(title, content, options){ this.setOptions(options); this.title = title; this.text = content; if (this.options.overlay) { this.overlay = new Element('div').setProperty('class', 'cbOverlay'); this.overlay.setStyles({ 'position': 'absolute', 'top': 0, 'left': 0, 'width': '100%', 'visibility': 'hidden' }).injectInside(document.body); } this.container = new Element('div').setProperty('class', 'cbContainer'); this.container.setStyles({ 'position': 'absolute', 'visibility': 'hidden' }).injectInside(document.body); this.box = new Element('div').setProperty('class', 'cbBox'); this.box.setStyles({ 'width': this.options.width+'px', 'overflow': 'auto' }).injectInside(this.container); if (this.box.getStyle('background-color') == '' || this.box.getStyle('background-color') == 'transparent') { this.box.setStyle('background-color', this.container.getStyle('background-color')); } if( this.options.showCloseBtn ) { this.closeBtn = new Element('div').setProperty('class', 'cbCloseButton'); this.closeBtn.onclick = this.close.pass(['close'], this); this.closeBtn.injectInside(this.box); } this.header = new Element('h3').setProperty('class', 'cbHeader').appendText(this.title).injectInside(this.box); this.content = new Element('div').setProperty('class', 'cbContent').injectInside(this.box); if ($type(content) == 'element' ) { content.injectInside(this.content); } else { this.content.setHTML(this.text); } this.buttons = new Element('div').setProperty('class', 'cbButtons').injectInside(this.box); if (this.buttons.getStyle('background-color') == '' || this.buttons.getStyle('background-color') == 'transparent') { this.buttons.setStyle('background-color', this.box.getStyle('background-color')); } for (var i = 1; i <= this.options.buttons; i++) { if (typeof(this.options['button'+i]) == 'undefined') { this.options['button'+i] = 'Button'; } if ($type(this.options['button'+i]) == 'element') { this['button'+i] = this.options['button'+i] this['button'+i].injectInside(this.buttons); } else { this['button'+i] = new Element('input').setProperties({type: 'button', value: this.options['button'+i]}).injectInside(this.buttons); } if (typeof(this.options['button'+i]) == 'undefined') { this.options['onButton'+i] = Class.empty; } this['button'+i].setProperty('class', 'button cbButton'); this['button'+i].onclick = this.close.pass([this.options['onButton'+i]], this); } this.boxHeight = (this.box.offsetHeight < this.options.maxHeight) ? this.box.offsetHeight : this.options.maxHeight; this.boxHeight = (this.options.height > 0) ? this.options.height : this.boxHeight; this._position(); this.eventPosition = this._position.bind(this); window.addEvent('scroll', this.eventPosition).addEvent('resize', this.eventPosition); this.box.setStyle('display', 'none'); if (this.options.overlay) { this.fx1 = new Fx.Style(this.overlay, 'opacity', {duration:100}).custom(0, .8); } if (this.options.effect == 'grow') { this.container.setStyle('top', (Window.getScrollTop()+(Window.getHeight()/2))+'px'); var style = {}; style.height = 0; style.width = 0; if (this.options.horizontal != 'center') { style[this.options.horizontal] = (this.options.width/2)+'px'; } if (this.options.vertical == 'top') { style[this.options.vertical] = (Window.getScrollTop()+(this.boxHeight/2))+'px'; } else if (this.options.vertical == 'bottom') { style.top = (Window.getScrollTop()+Window.getHeight()-(this.boxHeight/2)-25)+'px'; } this.container.setStyles(style); this.container.setStyle('visibility', ''); this.fx2 = new Fx.Styles(this.container, {duration:100}); this.fx2.custom({ 'width': [0, this.options.width], 'margin-left': [0, -this.options.width/2], 'margin-right': [0, -this.options.width/2], 'height': [0, this.boxHeight], 'margin-top': [0, -this.boxHeight/2], 'margin-bottom': [0, -this.boxHeight/2] }).chain(function() { this.box.setStyles({ 'visibility': 'hidden', 'display': '', 'height': this.boxHeight+'px' }); new Fx.Style(this.box, 'opacity', {duration:100}).custom(0, 1).chain(function() { if (this.options.delay > 0) { var fn = function () { this.close() }.bind(this).delay(this.options.delay); } }.bind(this)); }.bind(this)); } else { this.container.setStyles({ 'height': this.boxHeight, 'width': this.options.width, 'left': '', 'visibility': 'hidden' }); this.box.setStyles({ 'visibility': '', 'display': '', 'height': this.boxHeight+'px' }); this.fx2 = new Fx.Styles(this.container, {duration:100}); var special = {}; if (this.options.horizontal != 'center') { special[this.options.horizontal] = [-this.options.width, 0]; } else { this.container.setStyles({ 'left': '50%', 'margin-left': (-this.options.width/2)+'px', 'margin-right': (-this.options.width/2)+'px' }); } if (this.options.vertical == 'top') { special[this.options.vertical] = [Window.getScrollTop()-this.boxHeight, Window.getScrollTop()]; } else if (this.options.vertical == 'bottom') { special.top = [Window.getScrollTop()+Window.getHeight(), Window.getScrollTop()+Window.getHeight()-this.boxHeight-25]; } else { this.container.setStyles({ 'top': (Window.getScrollTop()+(Window.getHeight()/2))+'px', 'margin-top': (-this.boxHeight/2)+'px', 'margin-bottom': (-this.boxHeight/2)+'px' }); } special.opacity = [0, 1]; this.fx2.custom(special).chain(function() { if (this.options.delay > 0) { var fn = function () { this.close() }.bind(this).delay(this.options.delay); } }.bind(this)); } }, _position: function() { var wHeight = (Window.getScrollHeight() > Window.getHeight()) ? Window.getScrollHeight() : Window.getHeight(); //var bHeight = this.container.getStyle('height').toInt(); var lr = (this.options.effect == 'grow') ? this.options.width/2 : 0; var tb = (this.options.effect == 'grow') ? this.boxHeight/2 : 0; if (this.options.overlay) { this.overlay.setStyles({height: wHeight+'px'}); } switch(this.options.vertical) { case 'top': this.container.setStyle('top', (Window.getScrollTop()+tb)+'px'); break; case 'middle': this.container.setStyle('top', (Window.getScrollTop()+(Window.getHeight()/2))+'px'); break; case 'bottom': this.container.setStyle('top', (Window.getScrollTop()+Window.getHeight()-this.boxHeight+tb-25)+'px'); break; } if (this.options.horizontal == 'center') { this.container.setStyle('left', '50%'); } else { this.container.setStyle(this.options.horizontal, lr+'px'); } }, close: function(fn) { for (var i = 1; i <= this.options.buttons; i++) { this['button'+i].onclick = null; } if (this.options.overlay) {this.fx1.clearTimer();} this.fx2.clearTimer(); if (typeof(fn) == 'function') { fn(); } if (this.options.overlay) {new Fx.Style(this.overlay, 'opacity', {duration:250}).custom(.8, 0);} new Fx.Style(this.container, 'opacity', { duration:250, onComplete: function() { window.removeEvent('scroll', this.eventPosition).removeEvent('resize', this.eventPosition); if (this.options.overlay) { this.overlay.remove(); } try{ this.container.remove(); } catch(e){} }.bind(this) }).custom(1, 0); } }); MooPrompt.implement(new Chain);/* Slimbox v1.71 - The ultimate lightweight Lightbox clone (c) 2007-2009 Christophe Beyls MIT-style license. */ var Slimbox=(function(){var F=window,n=Browser.Engine.trident4,u,g,G=-1,o,w,E,v,y,M,s,m={},t=new Image(),K=new Image(),I,a,h,q,J,e,H,c,A,L,x,i,d,C;F.addEvent("domready",function(){$(document.body).adopt($$(I=new Element("div",{id:"lbOverlay",events:{click:D}}),a=new Element("div",{id:"lbCenter"}),H=new Element("div",{id:"lbBottomContainer"})).setStyle("display","none"));h=new Element("div",{id:"lbImage"}).injectInside(a).adopt(q=new Element("div",{styles:{position:"relative"}}).adopt(J=new Element("a",{id:"lbPrevLink",href:"#",events:{click:B}}),e=new Element("a",{id:"lbNextLink",href:"#",events:{click:f}})));c=new Element("div",{id:"lbBottom"}).injectInside(H).adopt(new Element("a",{id:"lbCloseLink",href:"#",events:{click:D}}),A=new Element("div",{id:"lbCaption"}),L=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}))});function z(){var N=F.getScroll(),O=F.getSize();$$(a,H).setStyle("left",N.x+(O.x/2));if(v){I.setStyles({left:N.x,top:N.y,width:O.x,height:O.y})}}function l(N){["object",n?"select":"embed"].forEach(function(P){Array.forEach(document.getElementsByTagName(P),function(Q){if(N){Q._slimbox=Q.style.visibility}Q.style.visibility=N?"hidden":Q._slimbox})});I.style.display=N?"":"none";var O=N?"addEvent":"removeEvent";F[O]("scroll",z)[O]("resize",z);document[O]("keydown",p)}function p(O){var N=O.code;return u.closeKeys.contains(N)?D():u.nextKeys.contains(N)?f():u.previousKeys.contains(N)?B():false}function B(){return b(w)}function f(){return b(E)}function b(N){if(N>=0){G=N;o=g[N][0];w=(G||(u.loop?g.length:0))-1;E=((G+1)%g.length)||(u.loop?0:-1);r();a.className="lbLoading";m=new Image();m.onload=k;m.src=o}return false}function k(){a.className="";d.set(0);h.setStyles({backgroundImage:"url("+o+")",display:""});q.setStyle("width",m.width);$$(q,J,e).setStyle("height",m.height);A.set("html",g[G][1]||"");L.set("html",(((g.length>1)&&u.counterText)||"").replace(/{x}/,G+1).replace(/{y}/,g.length));if(w>=0){t.src=g[w][0]}if(E>=0){K.src=g[E][0]}M=h.offsetWidth;s=h.offsetHeight;var P=Math.max(0,y-(s/2)),N=0,O;if(a.offsetHeight!=s){N=i.start({height:s,top:P})}if(a.offsetWidth!=M){N=i.start({width:M,marginLeft:-M/2})}O=function(){H.setStyles({width:M,top:P+s,marginLeft:-M/2,visibility:"hidden",display:""});d.start(1)};if(N){i.chain(O)}else{O()}}function j(){if(w>=0){J.style.display=""}if(E>=0){e.style.display=""}C.set(-c.offsetHeight).start(0);H.style.visibility=""}function r(){m.onload=$empty;m.src=t.src=K.src=o;i.cancel();d.cancel();C.cancel();$$(J,e,h,H).setStyle("display","none")}function D(){if(G>=0){r();G=w=E=-1;a.style.display="none";x.cancel().chain(l).start(0)}return false}Element.implement({slimbox:function(N,O){$$(this).slimbox(N,O);return this}});Elements.implement({slimbox:function(N,Q,P){Q=Q||function(R){return[R.href,R.title]};P=P||function(){return true};var O=this;O.removeEvents("click").addEvent("click",function(){var R=O.filter(P,this);return Slimbox.open(R.map(Q),R.indexOf(this),N)});return O}});return{open:function(P,O,N){u=$extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},N||{});x=new Fx.Tween(I,{property:"opacity",duration:u.overlayFadeDuration});i=new Fx.Morph(a,$extend({duration:u.resizeDuration,link:"chain"},u.resizeTransition?{transition:u.resizeTransition}:{}));d=new Fx.Tween(h,{property:"opacity",duration:u.imageFadeDuration,onComplete:j});C=new Fx.Tween(c,{property:"margin-top",duration:u.captionAnimationDuration});if(typeof P=="string"){P=[[P,O]];O=0}y=F.getScrollTop()+(F.getHeight()/2);M=u.initialWidth;s=u.initialHeight;a.setStyles({top:Math.max(0,y-(s/2)),width:M,height:s,marginLeft:-M/2,display:""});v=n||(I.currentStyle&&(I.currentStyle.position!="fixed"));if(v){I.style.position="absolute"}x.set(0).start(u.overlayOpacity);z();l(1);g=P;u.loop=u.loop&&(g.length>1);return b(O)}}})(); // AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED) Slimbox.scanPage = function() { $$("a").filter(function(el) { return el.rel && el.rel.test(/^lightbox/i); }).slimbox({/* Put custom options here */}, null, function(el) { return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel)); }); }; if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) { window.addEvent("domready", Slimbox.scanPage); }